using System;
using System.Collections.Generic;
using System.Text;
using Xyne.Templates;
using GarageGames.Torque.Core;
using Xyne.Components;
using GarageGames.Torque.Sim;
using Microsoft.Xna.Framework.Input;
using GarageGames.Torque.Platform;
using Microsoft.Xna.Framework;
using GarageGames.Torque.Materials;
using GarageGames.Torque.T2D;
using Xyne.Templates.PuzzlePieceTemplate;
using Xyne.Objects;

namespace Xyne.Regions
{
    /// <summary>
    /// Where the magic happens, 'nough said.
    /// </summary>
    public abstract class PuzzleRegion
    {
        // Unload callback delegate
        public delegate void UnloadPatternDelegate(int numGems);
        // Bounds for the region
        private Rectangle bounds;
        private QueueRegion queueRegion;

        public Rectangle Bounds
        {
            get { return bounds; }
            set { bounds = value; }
        }

        public QueueRegion QueueRegion
        {
            get
            {
                return queueRegion;
            }

            set
            {
                queueRegion = value;
            }
        }

        public PuzzleRegion(Rectangle bounds, QueueRegion queueRegion)
        {
            this.bounds = bounds;
            this.QueueRegion = queueRegion;
        }

        /// <summary>
        /// Load a pattern, start the sweep.
        /// </summary>
        /// <param name="pattern">The pattern, any size</param>
        /// <param name="onUnload">Callback for if the sweep finishes</param>
        /// <returns>If there is a single pattern matched</returns>
        public abstract bool LoadPattern(PatternValue[,] pattern, UnloadPatternDelegate onUnload);

        /// <summary>
        /// Unloads a pattern, stopping the sweep.
        /// </summary>
        /// <returns>Number of gems activated</returns>
        public abstract int UnloadPattern();

        /// <summary>
        /// Starts the game logic.
        /// </summary>
        public abstract void Start();
    }
}
